﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TrapCollider : MonoBehaviour
{
    public AudioClip ColliderClip;

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.name=="Role_XiaoQi" && this.gameObject.tag == "Trap")
        {
            Parkour.Instance.Death();
            AudioSource a= Camera.main.GetComponent<AudioSource>();
            a.clip = ColliderClip;
            a.Play();
            a.loop = false;

        }
        else
        {
            Camera.main.GetComponent<AudioSource>().Stop();
            //分数
            GameObject.Find("UI_Game").SendMessage("AddNum", 5);
            //关卡解锁
            if (!LevelSingleton.GetInstance().levelData.ContainsKey(5))
            {
                LevelSingleton.GetInstance().levelData.Add(5, 1);
            }
            
            PlayerPrefs.SetInt("5", 1);
            Parkour.Instance.ani.SetTrigger("Happy");
            Parkour.Instance.canRun = false;
            GameObject.Find("Canvas").SendMessage("EndDialog");
        }
    }

}
